Skip to content

[minor] Transition internal GHE repo sync to native Git ref mirroring - #658

Draft
devanshraghuvanshi wants to merge 19 commits into
mainfrom
MASCORE-18527
Draft

devanshraghuvanshi wants to merge 19 commits into
mainfrom
MASCORE-18527

Conversation

@devanshraghuvanshi

Copy link
Copy Markdown
Contributor

Native Git Ref Mirroring Implemented:

.github/workflows/update-internal-repo.yaml:

  • Uses git clone --bare + git push --prune --force "refs/heads/:refs/heads/" "refs/tags/:refs/tags/" to target github.ibm.com/automation-paas-cd-pipeline/mas-gitops.
  • Configured to trigger on all push events (branches & tags), daily cron reconciliation (0 2 * * *), and manual workflow_dispatch.
  • Configured concurrency control (group: ghe-mirror-sync, cancel-in-progress: false) to serialize runs and prevent race conditions.

Obsolete Scripts Removed:

  • Deleted build/bin/copy-gitops.sh.

Documentation Updated:

  • CONTRIBUTING.md: Updated the Update Internal GHE Repo section to describe 1:1 ref mirroring and tag propagation.

@devanshraghuvanshi devanshraghuvanshi self-assigned this Nov 2, 2026
@devanshraghuvanshi
devanshraghuvanshi marked this pull request as ready for review November 3, 2026 05:38
fi
echo "Pushing mirror refs to https://github.ibm.com/${TARGET_REPO}..."
# Explicitly push heads and tags; avoid pushing internal GitHub pull-request refs
git push --prune --force "https://x-access-token:${GHE_TOKEN}@github.ibm.com/${TARGET_REPO}.git" "refs/heads/*:refs/heads/*" "refs/tags/*:refs/tags/*"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should clone and push with --mirror option for mirroring

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mnivedithaa

I tested using git clone --mirror and git push --mirror, but GitHub Enterprise rejects the push with:

! [remote rejected] refs/pull/1/head -> refs/pull/1/head (deny updating a hidden ref)
! [remote rejected] refs/pull/658/merge -> refs/pull/658/merge (deny updating a hidden ref)
error: failed to push some refs to 'https://github.ibm.com/automation-paas-cd-pipeline/mas-gitops.git'

Reason:
--mirror attempts to push everything in the repository, including GitHub's internal Pull Request data (refs/pull/). However, GitHub Enterprise treats refs/pull/ as protected read-only system data and blocks any external push trying to update it.

Why our approach works:
Using git clone --bare + git push --prune --force ... "refs/heads/:refs/heads/" "refs/tags/:refs/tags/" gives the exact 1:1 mirror of all actual branches, tags, commit history, and deletions (--prune), while avoiding GitHub's internal Pull Request references (refs/pull/*).

mnivedithaa
mnivedithaa previously approved these changes Nov 6, 2026
tomklapiscak
tomklapiscak previously approved these changes Nov 7, 2026
@devanshraghuvanshi
devanshraghuvanshi marked this pull request as draft November 12, 2026 09:37

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants